import request from '@/utils/request'

export default {
    findAll:function () {
        return request({
            url:'/hnister-security-service/rest/pt/resources',
            method:'get'
        })
    },
    /**
     * 分页及条件查询
     * @param queryParams
     * //分页参数 pageSize <= 0 返回所有 不进行分页
     * queryParams 携带信息：
     * Integer pageCount, Integer pageSize
     * //查询条件 group <= 0 查询所有组       likeWord不为空匹配查询 name & url          method <g 0 查询所有
     * Integer groupId,String likeWord,Integer method
     */
    findByPageAndCondition:function (queryParams) {
        return request({
            url:'/hnister-security-service/rest/pt/resources/@/for=page&condition',
            method:'get',
            params:{
                ...queryParams,
            }
        })
    },
    findById(resourceId){
        return request({
            url:'/hnister-security-service/rest/pt/resource/'+resourceId,
            method:'get'
        })
    },
    add:function (resource) {
        return request({
            url:'/hnister-security-service/rest/pt/resource',
            method:'post',
            data:resource
        })
    },
    deleteById:function (id) {
        return request({
            url:'/hnister-security-service/rest/pt/resource/'+id,
            method:'delete'
        })
    },
    //通过roleId 获取该role所拥有的所有资源id
    findByRoleId:function (roleId) {
        return request({
            url:'/hnister-security-service/rest/pt/resources/roleId/'+roleId,
            method:'get'
        })
    },
    edit(resource){
        return request({
            url:'/hnister-security-service/rest/pt/resource',
            method:'put',
            data:resource
        })
    }
}

